package com.shan.design.combination.safe;


import java.util.ArrayList;
import java.util.List;

/**
 * 安全文件夹类
 * @author shanzheng
 * @date 2018-12-02 17:24
 **/
public class FolderSafe extends AbstractFileSafe{
    private List<AbstractFileSafe> abstractFileSafeList = new ArrayList<>();
    private String name;

    public FolderSafe(String name) {
        this.name = name;
    }

    public void add(AbstractFileSafe abstractFileSafe) {
        abstractFileSafeList.add(abstractFileSafe);
    }
    public void remove(AbstractFileSafe abstractFileSafe) {
        abstractFileSafeList.remove(abstractFileSafe);
    }
    public AbstractFileSafe getChild(int i) {
        return abstractFileSafeList.get(i);
    }
    @Override
    public void killVirus() {
        //模拟杀毒
        System.out.println("****对文件夹'" + name + "'进行杀毒");
        for (AbstractFileSafe abstractFileSafe : abstractFileSafeList) {
            abstractFileSafe.killVirus();
        }
    }
}
